package cn.bkrc.service.impl;

import cn.bkrc.entity.Emp;
import cn.bkrc.reporsity.EmpRepository;
import cn.bkrc.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class EmpServiceImpl implements EmpService {
    @Autowired
    EmpRepository empRepository;

    @Override
    public Emp findEmpById(Integer eid) {
        Emp emp=empRepository.findById(eid).get();
        return  emp;
    }

    @Override
    public List<Emp> findAllEmps() {
        return empRepository.findAll();
    }

    @Override
    public Emp addEmp(Emp emp) {
        Emp emp1=empRepository.save(emp);
        return  emp1;
    }

    @Override
    public Emp updeEmp(Emp emp) {
        Emp emp1=empRepository.save(emp);
        return  emp1;
    }

    @Override
    public void deleteEmpById(Integer eid) {
        empRepository.deleteById(eid);
    }
}
